package com.hrbxlh.action;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.google.common.collect.Maps;
import com.hrbxlh.util.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.UnexpectedRollbackException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.hrbxlh.actionImpl.ClassActionImpl;
import com.hrbxlh.actionImpl.CourseActionImpl;
import com.hrbxlh.actionImpl.DepActionImpl;
import com.hrbxlh.actionImpl.DepartMentActionImpl;
import com.hrbxlh.actionImpl.LoginActionImpl;
import com.hrbxlh.actionImpl.MemberActionImpl;
import com.hrbxlh.actionImpl.MyCourseActionImpl;
import com.hrbxlh.actionImpl.ParamActionImpl;
import com.hrbxlh.actionImpl.ProfessionActionImpl;
import com.hrbxlh.actionImpl.RoleActionImpl;
import com.hrbxlh.exception.VirtualMachineAllocateException;

/**
* -------------------------------------------------------
* Copyright (c) 2017, 鑫联华信息科技股份有限公司
* All rights reserved.
* FileName：MemberAction.java
* Description：人员action类
* History：
* Date           Author               Desc
* 2017.3.29		  sy                   建立
* -------------------------------------------------------
*/

@Controller
public class MemberAction {

	@Autowired
	@Qualifier("memberActionImpl")
	private MemberActionImpl memberActionImpl;
	
	@Autowired
	@Qualifier("depActionImpl")
	private DepActionImpl depActionImpl;
	
	@Autowired
	@Qualifier("roleActionImpl")
	private RoleActionImpl roleActionImpl;
	
	@Autowired
	@Qualifier("departMentActionImpl")
	private DepartMentActionImpl departMentActionImpl;
	
	@Autowired
	@Qualifier("professionActionImpl")
	private ProfessionActionImpl professionActionImpl;
	
	@Autowired
	@Qualifier("courseActionImpl")
	private CourseActionImpl courseActionImpl;
	
	@Autowired
	@Qualifier("myCourseActionImpl")
	private MyCourseActionImpl myCourseActionImpl;
	
	@Autowired
	@Qualifier("loginActionImpl")
	private LoginActionImpl loginActionImpl;
	
	@Autowired
	@Qualifier("paramActionImpl")
	private ParamActionImpl paramActionImpl;
	
	@Autowired
	@Qualifier("classActionImpl")
	private ClassActionImpl classActionImpl;
	
	
	/**
	 * @param request
	 * @param response
	 * @return  跳转到添加人员页面
	 * @throws IOException
	 */
	@RequestMapping(value = "/skipAddMember", method = RequestMethod.GET)
	public ModelAndView skipAddMember(String jsonStr,HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			//参数
			Map<String, Object> paramMap = new HashMap<String, Object>();
			//获取页面参数值
			Map<String,Object> preParamMap = mapper.readValue(jsonStr, resultMap.getClass());
			//获取全部部门信息
			List<Map<String, Object>> depList = depActionImpl.getDepList(paramMap);
			//获取全部角色信息
			List<Map<String, Object>> roleList = roleActionImpl.getRoleList(paramMap);
			//获取全部院系
			List<Map<String,Object>> departMentList = departMentActionImpl.getDepartMentList(paramMap);
			//获取全部专业
//			List<Map<String,Object>> professionList = professionActionImpl.getProfessionList(paramMap);
			//查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			//返回值
			resultMap.put("depList", depList);
			resultMap.put("roleList", roleList);
			resultMap.put("departMentList", departMentList);
//			resultMap.put("professionList", professionList);
		    //添加页面名称
			if(String.valueOf(preParamMap.get("pageType")).equals("1")){
				pageName = "pc/addTeacher";
			}else if(String.valueOf(preParamMap.get("pageType")).equals("2")){
				pageName = "pc/addUser";
			}
			
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转添加人员页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}

	/**
	 * @param request
	 * @param response
	 * @return  添加人员,传回姓名，性别，电话，登录名，密码，角色id,部门id。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/addMember", method = RequestMethod.POST)
	public void addMember(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		//成功失败标识
		String resultMark = "fail";
		try {
			/*模拟参数开始*/
			//Map<String, Object> mapUse = new HashMap<String, Object>();
			//mapUse.put("userSex", "M");
			//mapUse.put("telephoneNum", "15245020967");
			//mapUse.put("userName", "test1");
			//mapUse.put("password", "123456");
			//mapUse.put("loginName", "哈哈");
			//mapUse.put("roleId",1);
			//mapUse.put("depId",1);
			//jsonStr = mapper.writeValueAsString(mapUse);
			/*模拟参数结束*/
			String pwd = "";
			String password = "";
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			if((String)paramMap.get("password")!=null&&(String)paramMap.get("password")!=""){
				//将密码和工号/学号一起用MD5加密
				pwd = (String)paramMap.get("stuorteaId")+(String)paramMap.get("password");
				password = DigestUtils.md5Hex(pwd);
			}else{
				//将密码默认给6个0和工号/学号一起用MD5加密
				pwd = (String)paramMap.get("stuorteaId")+"000000";
				password = DigestUtils.md5Hex(pwd);
			}
			
			paramMap.put("password", password);
			//添加人员
			Map<String, String> resultFlag = memberActionImpl.addMember(paramMap);
			resultMark = (resultFlag.get("result").equals("true")) ? "success" : "fail";
			resultMap.put("result", resultMark);
			if(resultMark.equals("fail")){
				resultMap.put("errorMsg", resultFlag.get("errorMsg"));
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("添加人员出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @param request
	 * @param response
	 * @return  进修改人员页面,需要人员id，传回人员全部信息，角色列表，部门列表。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/skipSaveMember", method = RequestMethod.GET)
	public ModelAndView skipSaveMember(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			/*模拟参数开始*/
			//Map<String, Object> mapUse = new HashMap<String, Object>();
			//mapUse.put("userNum", 1);
			//jsonStr = mapper.writeValueAsString(mapUse);
			/*模拟参数结束*/

			//获取页面参数值
			Map<String,Object> preParamMap = mapper.readValue(jsonStr, resultMap.getClass());
			Map<String, Object> MemMap = memberActionImpl.getAdminByStuorteaId(String.valueOf(preParamMap.get("stuorteaId")));
			//参数
			Map<String, Object> paramMap = new HashMap<String, Object>();
			//获取全部部门信息
			List<Map<String, Object>> depList = depActionImpl.getDepList(paramMap);
			//获取全部角色信息
			List<Map<String, Object>> roleList = roleActionImpl.getRoleList(paramMap);
			//获取全部院系
			List<Map<String,Object>> departMentList = departMentActionImpl.getDepartMentList(preParamMap);
			resultMap.put("departMentList", departMentList);
			//查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			//返回值
			resultMap.put("depList", depList);
			resultMap.put("roleList", roleList);
			resultMap.put("user", MemMap.get("memberMap")); 
		    //修改页面名称
			pageName = "pc/saveUser";
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转修改人员页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**
	 * @param request
	 * @param response  
	 * @return  修改人员,传回人员id，姓名，性别，电话，登录名，角色id,部门id，邮箱.
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/saveMember", method = RequestMethod.POST)
	public void saveMember(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		//成功失败标识
		String resultMark = "fail";
		try {
			/*模拟参数开始*/
			//Map<String, Object> mapUse = new HashMap<String, Object>();
			//mapUse.put("userNum", 1);
			//mapUse.put("userSex", "F");
			//mapUse.put("telephoneNum", "15245020967");
			//mapUse.put("userName", "test1");
			//mapUse.put("loginName", "修改好使么");
			//mapUse.put("roleId", 1);
			//mapUse.put("depId", 1);
			//jsonStr = mapper.writeValueAsString(mapUse);
			/*模拟参数结束*/
			
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
            //修改人员
			boolean flag = memberActionImpl.saveMember(paramMap);
			
			resultMark = (flag == true) ? "success" : "fail";
			resultMap.put("result", resultMark);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("修改人员出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @param request
	 * @param response
	 * @return  删除人员,传回人员id集合。List<String>形式   jsonStr = ["1","2","3"...]
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/delMembers", method = RequestMethod.POST)
	public void delMembers(String jsonStr,int memType, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		//成功失败标识
		String resultMark = "fail";
		//用于转换参数
		List<String> list = new ArrayList<String>();
		Map<String,Object> paramMap = new HashMap<String,Object>();
		try {
			/*模拟参数开始*/
			//List<Integer> listUse = new ArrayList<Integer>();
			//listUse.add(2);
			//listUse.add(3);
			//jsonStr = mapper.writeValueAsString(listUse);
			/*模拟参数结束*/
			
			//获取参数值
			paramMap = mapper.readValue(jsonStr, paramMap.getClass());
			System.out.println("memType"+memType+"paramMap"+paramMap);
			 List<String> paramList = (List<String>) paramMap.get("list");
			 int marks = Integer.valueOf(String.valueOf(paramMap.get("marks")));
			Map<String,Object> returnMap = new HashMap<String,Object>();
            //删除人员
			returnMap= memberActionImpl.delMember(paramList,request,memType,marks);
			resultMark = (((String) returnMap.get("resultFlag")).equals("true")) ? "success" : "fail";
			resultMap.put("result", resultMark);
			resultMap.put("resultMsg", returnMap.get("resultMsg"));
			resultMap.put("paramMap", paramMap);
		} catch (Exception e) {
			e.printStackTrace();
			resultMap.put("resultMsg", "删除人员出现异常");
			logger.error("删除人员出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @param pageNow,pageSize(一般是10)，页数从1开始，第一页pageNow传1
	 * @return  人员列表页面，传回全部人员信息。进页面，翻页，条件查询都是这个。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getMemberList", method = RequestMethod.GET)
	public ModelAndView getMemberList(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			/*模拟参数开始*/
			/*Map<String, Object> mapUse = new HashMap<String, Object>();
			mapUse.put("pageNow", 1);
			mapUse.put("pageSize", 10);
			mapUse.put("roleId", 2);//区分是查什么角色   1.学生列表  2.教师列表  3，4用户管理（管理员或超级管理员列表）
			jsonStr = mapper.writeValueAsString(mapUse);*/
			/*模拟参数结束*/
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//搜索框对象
			Map<String, Object> SearObjectMap = new HashMap<String,Object>();
			if(preParamMap.get("departmentId")!=null){
				SearObjectMap.put("departmentId", preParamMap.get("departmentId"));
			}if(preParamMap.get("userName")!=null){
				SearObjectMap.put("userName", preParamMap.get("userName"));
			}if(preParamMap.get("depId")!=null){
				SearObjectMap.put("depId", preParamMap.get("depId"));
			}
			System.out.println("传的参数不对吗"+preParamMap);
			//获取人员列表信息
			Map<String, Object> resultAllMap = memberActionImpl.getMemberList(preParamMap);
			if(String.valueOf(preParamMap.get("roleMark"))!="3"||String.valueOf(preParamMap.get("roleMark"))!="4"){
				//获取全部院系(说明查的是用户管理不需要院系)
				preParamMap.put("departmentId", 0);
				System.out.println("获取全部院系(说明查的是用户管理不需要院系)");
				List<Map<String,Object>> departMentList = departMentActionImpl.getDepartMentList(preParamMap);
				resultMap.put("departMentList", departMentList);
			}
			//查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			//获取全部部门信息
//			List<Map<String, Object>> depList = depActionImpl.getDepList(preParamMap);
			preParamMap.put("depId", "");
			//获取全部部门信息
			List<Map<String, Object>> depAllList = depActionImpl.getDepList(preParamMap);
			//返回值
			resultMap.put("memberList", resultAllMap.get("memberList"));
			resultMap.put("depAllList", depAllList);
			resultMap.put("totalPage", resultAllMap.get("totalPage"));
			resultMap.put("pageNow", resultAllMap.get("pageNow"));
			resultMap.put("pageSize", preParamMap.get("pageSize"));
			resultMap.put("userName", preParamMap.get("userName"));
			resultMap.put("stuorteaId", preParamMap.get("stuorteaId"));
			resultMap.put("SearObjectMap", SearObjectMap);
			if(String.valueOf(preParamMap.get("roleMark")).equals("2")){
				//跳到教师列表
				pageName = "pc/memberList";
			}if(String.valueOf(preParamMap.get("roleMark")).equals("4")||String.valueOf(preParamMap.get("roleMark")).equals("3")){
				//超级管理员（用户管理）
				pageName = "pc/adminList";
			}if(String.valueOf(preParamMap.get("roleMark")).equals("1")){
				//跳到班级下详情中的学生列表
				pageName = "pc/classDetail";
			}
			
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转修改人员页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**
	 * @description 跳转到登录页面
	 * @param request,response
	 * @return  登录页面
	 * @throws IOException
	 */
	@RequestMapping(value = "/beforeLogin", method = RequestMethod.GET)
	public ModelAndView beforeLogin(HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		ObjectMapper mapper = new ObjectMapper();
		try {
			
			pageName = "public/login";
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转登录页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(returnMap);
			resultMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, resultMap);
	}
	
	/**
	 * @description 获取验证码
	 * @param request,response
	 * @return  登录页面
	 * @throws IOException
	 */
	@RequestMapping(value = "/captcha", method = RequestMethod.GET)
	public void captcha(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	 	try{
	 		System.out.println("验证码");
	 		//得到验证码
	 		CaptchaUtil.outputCaptcha(request, response);
	 	}catch(Exception e){
	 		e.printStackTrace();
	 	}        
    }
	
	/**
	 * @description 登录提交的action
	 * @param String :json表单信息 , request,response
	 * @return  成功失败，以及失败信息
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public void login(String jsonStr, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws IOException {
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		String resultMark = "fail";
		try {
			/*模拟参数开始*/
			//Map<String, Object> mapUse = new HashMap<String, Object>();
			//mapUse.put("loginName", "123");
			//mapUse.put("password", "123456");
			//mapUse.put("verficateCode", "tku6");
			//mapUse.put("rememberMe", "true");
			//jsonStr = mapper.writeValueAsString(mapUse);
			/*模拟参数结束*/
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//登录验证
			Map<String ,Object> resultFlag = memberActionImpl.login(preParamMap, request, session);
			//返回成功失败
			resultMark = (String.valueOf(resultFlag.get("result")).equals("true")) ? "success" : "fail";
			resultMap.put("result", resultMark);
			resultMap.put("memberMessage", resultFlag.get("memberMessage"));
			if(resultMark.equals("fail")){
				resultMap.put("errorMsg", resultFlag.get("errorMsg"));
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("登录出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的：" + reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @description 跳转到主页
	 * @param request,response
	 * @return  登录页面
	 * @throws IOException
	 */
	@RequestMapping(value = "/skipMainPage", method = RequestMethod.GET)
	public ModelAndView skipMainPage(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException {		
		
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		ObjectMapper mapper = new ObjectMapper();
		try {
			String stuId = (String)session.getAttribute("stuorteaId");
			if(stuId==null||stuId.equals("")){
				System.out.println("应该跳到登陆页啊");
				pageName = "public/login";
			}else{
				System.out.println("session"+session);
				int roleId = (Integer)session.getAttribute("realRoleId");
				String stuorteaId = (String)session.getAttribute("stuorteaId");
				String userName = (String)session.getAttribute("userName");
				Map<String,Object> paramMap = paramActionImpl.getParamDetail();
				//查询当前人的消息
				List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
				resultMap.put("noticeList", noticeList);
				resultMap.put("paramMap", paramMap);
				resultMap.put("roleId", roleId);
				resultMap.put("stuorteaId", stuorteaId);
				resultMap.put("userName", userName);
				pageName = "pc/main";
			}
			
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转主页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**
	 * @description 退出系统
	 * @param request,response
	 * @return  登录页面
	 * @throws IOException
	 */
	@RequestMapping(value = "/logOut", method = RequestMethod.GET)
	public ModelAndView logOut(HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {		
		
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		ObjectMapper mapper = new ObjectMapper();
		try {
			
			loginActionImpl.upLogin(session);
//			pageName = "redirect:/beforeLogin";
			pageName = "public/login";
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("退出系统出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**
	 * @description 忘记密码判断(没用上)
	 * @param request,response
	 * @return  是否成功的标识，result true成功，false失败，errorMsg 错误信息
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/forgetPasswordJudge", method = RequestMethod.POST)
	public void forgetPasswordJudge(String jsonStr,HttpServletResponse response) throws IOException {

		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		ObjectMapper mapper = new ObjectMapper();
		try {
			/*模拟参数开始*/
			//Map<String, Object> mapUse = new HashMap<String, Object>();
			//mapUse.put("loginName", "123");
			//jsonStr = mapper.writeValueAsString(mapUse);
			/*模拟参数结束*/
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			Map<String, Object> memberMessage = memberActionImpl.getMemberByLogName((String)preParamMap.get("loginName"));
			if(memberMessage == null || memberMessage.get("loginName") == null){
				resultMap.put("result", "fail");
				resultMap.put("errorMsg", "用户名不存在");
			}else{
				resultMap.put("result", "success");
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("忘记密码判断出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的：" + reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
		
	/**
	 * @description 跳转到忘记密码页面（没用上）
	 * @param request,response
	 * @return  
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/skipForgetPassword", method = RequestMethod.GET)
	public ModelAndView skipForgetPassword(String jsonStr, HttpServletRequest request) throws IOException {

		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		ObjectMapper mapper = new ObjectMapper();
		try {
			/*模拟参数开始*/
			//Map<String, Object> mapUse = new HashMap<String, Object>();
			//mapUse.put("loginName", "123");
			//jsonStr = mapper.writeValueAsString(mapUse);
			/*模拟参数结束*/
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			resultMap = preParamMap;
			pageName = "pc/forgetPassword";
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			logger.error("忘记密码判断出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的:"+reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
		
	/**
	 * 短信验证码（没用上）
	 * @param 电话号
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getCode", method = RequestMethod.POST)
	public void getCode(String jsonStr, HttpServletResponse response) throws IOException {

		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		ObjectMapper mapper = new ObjectMapper();
		try {
			/*模拟参数开始*/
			//Map<String, Object> mapUse = new HashMap<String, Object>();
			//mapUse.put("phoneNum", "15546152160");
			//jsonStr = mapper.writeValueAsString(mapUse);
			/*模拟参数结束*/
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			String phoneNum = (String)preParamMap.get("phoneNum");
			//获取验证码
			String code = SendMsgUtil.createRandomVcode();
			//发送短信
			SendMsgUtil.sendMsgYZ(phoneNum, code);
			System.out.println("短信验证码："+code);
			PrintWriter write = response.getWriter();
			write.println(code);
			write.flush();
		}catch (Exception e) {
			logger.error("短信验证码出现异常", e);
		}
	}
	
	/**
	 * @description 忘记密码提交，（没用上）
	 * @param 登录名，密码，（需要页面判断验证码输入是否正确）
	 * @return success成功   fail失败
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/forgetPasswordSubmit", method = RequestMethod.POST)
	public void forgetPasswordSubmit(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		Map<String,Object> returnMap = new HashMap<String,Object>();		
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		//成功失败标识
		String resultMark = "fail";
		try {
			/*模拟参数开始*/
			//Map<String, Object> map = new HashMap<String, Object>();
			//map.put("loginName", "哈哈");
			//map.put("password", "000");
			//jsonStr = mapper.writeValueAsString(map);
			/*模拟参数结束*/
			
			//获取参数值
			resultMap = mapper.readValue(jsonStr, resultMap.getClass());
			//密码md5加密
			String password = DigestUtils.md5Hex((String)resultMap.get("password"));
			resultMap.put("password", password);
			//修改密码
			boolean flag = memberActionImpl.savePassword(resultMap);
			resultMark = (flag == true) ? "success" : "fail";
			returnMap.put("result", resultMark);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("修改密码出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(returnMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @param 用户详情
	 * @return  人员Id。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getMemberDetailById", method = RequestMethod.GET)
	public ModelAndView getMemberDetailById(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		System.out.println("用户详情");
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			/*模拟参数开始*/
			/*Map<String, Object> mapUse = new HashMap<String, Object>();
			mapUse.put("stuorteaId", "2222");//区分是查什么角色   1.学生列表  2.教师列表  3，4用户管理（管理员或超级管理员列表）
			mapUse.put("pageNow", 0);
			jsonStr = mapper.writeValueAsString(mapUse);*/
			/*模拟参数结束*/
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			System.out.println("参数不对"+preParamMap);
			//获取人员列表信息
			Map<String, Object> resultAllMap = memberActionImpl.getMemberDetailById(preParamMap);
		
			String[] interfaceNameArrUse = {"server_address","project_name"};
			String[] valueArrUse = PropertiesUtil.getUrl(interfaceNameArrUse);
			String urlUse = "";
			for(String value:valueArrUse){
				urlUse += value;
			}
			//返回图片地址
            String returnUrl= urlUse+"images/pc";
			//返回值
            List<Map<String, Object>> memberList = new ArrayList<Map<String, Object>>();
            if(resultAllMap.get("memberList")!=null){
            	memberList = (List<Map<String, Object>>) resultAllMap.get("memberList");
            }
			resultMap.put("memberList",memberList);
			resultMap.put("imageUrl", returnUrl);
			resultMap.put("preParamMap",preParamMap);
			//查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			if((Integer)preParamMap.get("param")==1){
				//教师详情列表页面名称
				pageName = "pc/myInfo";
			}if((Integer)preParamMap.get("param")==2){
				//查所所有院系
//				List<Map<String,Object>> departMentList = departMentActionImpl.getDepartMentList(preParamMap);
//				resultMap.put("departMentList", departMentList);
				//查当前登陆人的所有课程
				List<Map<String,Object>> courseList = courseActionImpl.getTeaTeachCourse(preParamMap);
				resultMap.put("courseList", courseList);
				//查询某院系下的专业集合
//				preParamMap.put("departmentId", memberList.get(0).get("departmentId"));
//				List<Map<String, Object>> professionList = professionActionImpl.getProfessionList(preParamMap);
//				resultMap.put("professionList", professionList);
				//教师--我的信息页面名称
				pageName = "pc/teacherInfo";
			}if((Integer)preParamMap.get("param")==3){
				//查当前登陆人的所有课程
				List<Map<String,Object>> courseList = myCourseActionImpl.getStuCourse(preParamMap);
				resultMap.put("courseList", courseList);
				//学生--我的信息页面名称
				pageName = "pc/stuInfo";
			}
		    
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("人员详情页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**
	 * 详情页上传照片和简介
	 * 
	 * @param file
	 * @param response
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/insertImg", method = RequestMethod.POST)
	public ModelAndView insertImg(
			@RequestParam(value = "apkFile") MultipartFile apkFile,
			@RequestParam(value = "content") String content,
			@RequestParam(value = "stuorteaId") String stuorteaId,
			@RequestParam(value = "professionId") String professionId,
			@RequestParam(value = "departmentId") String departmentId,
			String jsonStr,
			HttpServletResponse response, HttpServletRequest request)
			throws Exception {
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		System.out.println("这两个到底是啥"+apkFile);
		//获取角色
		int roleId = (Integer) request.getSession().getAttribute("realRoleId");
		int selecetRoleId = (Integer) request.getSession().getAttribute("roleId");
		System.out.println("真实的角色"+roleId+"选择的角色"+selecetRoleId);
		String fileName = "";
		if(apkFile!=null){
			System.out.println("%%%%%%%%");
			fileName = apkFile.getOriginalFilename();
			
		}
		
		System.out.println("详情上传照片"+fileName+"content"+content+"professionId"+professionId+"departmentId"+departmentId+"jsonStr"+jsonStr);
		String textArea = "";
		if(jsonStr==null||jsonStr.equals("")){
			System.out.println("怎么走着了");
			textArea = content;
		}else{
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			textArea = String.valueOf(paramMap.get("textarea"));
//			System.out.println("转换前"+textArea);
		}
		if (textArea== null||textArea.equals("")) {
			textArea = "";
		} else if (content.length() == 0) {
			textArea = "";
		}
		textArea = textArea.replaceAll("\n", "<br>");
		textArea = textArea.replaceAll("\r", "<br>");
		System.out.println("转换后是啥"+textArea);
		String view = "";
		String reJsonStr = "";
		
		Map<String, Object> map = new HashMap<String, Object>();
		String json1 = "%7B%22pageNow%22:1,%22pageSize%22:10,%22professionId%22:"+professionId+",%22departmentId%22:"+departmentId+",%22roleId%22:"+roleId+",%22selecetRoleId%22:"+selecetRoleId+",%22roleMark%22:2%7D";
//		String json1 = "%7B%22pageNow%22:1,%22pageSize%22:10,%22professionId%22:0,%22departmentId%22:0,%22roleId%22:2,%22selecetRoleId%22:2%7D";
		
		
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {

			String fileName1 = "";
			// 获取上传文件类型的扩展名,先得到.的位置，再截取从.的下一个位置到文件的最后，最后得到扩展名
			String ext = fileName.substring(fileName.lastIndexOf(".") + 1,
					fileName.length());

			// 对扩展名进行小写转换
			ext = ext.toLowerCase();
			if (ext.equals("png")) {
				fileName1 = stuorteaId + "imageUrl." + ext;
			} else {
				fileName1 = stuorteaId + "imageUrl.png";
			}

			map.put("userContect", textArea);
			map.put("stuorteaId", stuorteaId);
			//查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			if (fileName != "") {
				System.out.println("走哪啊");
				String path = request.getSession().getServletContext()
						.getRealPath("/images/pc/" + fileName1);// 存放位置
				File destFile = new File(path);
				String file1 = String.valueOf(destFile);
				map.put("imageUrl", fileName1);
				System.out.println("apkFile.getInputStream()"+apkFile.getInputStream());
				FileUtils.copyInputStreamToFile(apkFile.getInputStream(),destFile);// 复制临时文件到指定目录下
			} else {
				System.out.println("走哪啊1");
				map.put("imageUrl", "");
			}
			System.out.println("图片是啥啊"+map.get("imageUrl"));
			 // 往数据库里面插入
			boolean resultFlag = memberActionImpl.updatImOrContent(map);
			if(resultFlag){
				System.out.println("重定向了");
				view = "redirect:/getMemberList?jsonStr=" + json1;
			}else{
				resultMap.put("errMsg", "添加教师基本信息失败");
				view = "public/pageerror";
			}
			
			
		} catch (Exception e) {
			resultMap.put("errMsg", "添加教师基本信息失败");
			e.printStackTrace();
			logger.error("人员详情页面出现异常", e);
			view = "public/pageerror";

		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(view, returnMap);
	}
	
	/**
	 * 教师/学生信息页修改（包含上传图片和修改简介）
	 * 
	 * @param file
	 * @param response
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/updateInfo", method = RequestMethod.POST)
	public ModelAndView updateInfo(
			@RequestParam(value = "apkFile") MultipartFile apkFile,String content, String sId,
			int professionId,int departmentId,String bdImage,String userName,String userSex,
			String tel,String pwd,String jsonStr,int param,
			HttpServletResponse response, HttpServletRequest request)
			throws Exception {
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		//获取参数值
		String textArea = "";
		if(jsonStr==null||jsonStr.equals("")){
			textArea = content;
		}else{
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			textArea = String.valueOf(paramMap.get("textarea"));
		}
		
		System.out.println("这两个updateInfo底是啥"+apkFile+"bdImage"+bdImage+"userName"+userName+"userSex"+userSex+"tel"+tel+"pwd"+pwd+"textArea"+textArea);
		String fileName = "";
		String stuorteaId = (String) request.getSession().getAttribute("stuorteaId");
		int roleId = (Integer) request.getSession().getAttribute("realRoleId");
		String json = "%7B%22pageNow%22:0,%22pageSize%22:10,%22stuorteaId%22:%22"+stuorteaId+"%22,%22param%22:2,%22postFlag%22:1,%22roleId%22:%22"+roleId+"%22,%22selecetRoleId%22:2%7D";
		String json1 = "%7B%22pageNow%22:0,%22pageSize%22:10,%22stuorteaId%22:%22"+stuorteaId+"%22,%22param%22:3,%22postFlag%22:1,%22roleId%22:%22"+roleId+"%22,%22selecetRoleId%22:1%7D";
		if(apkFile!=null){
			System.out.println("%%%%%%%%");
			fileName = apkFile.getOriginalFilename();
			
		}if(!bdImage.equals("")&&bdImage!=null){
			System.out.println("^^^^^^^^^^");
			String arr[] = bdImage.split("/");
			fileName = arr[2];
		}
		
		System.out.println("详情上传照片"+fileName+"content"+content+"professionId"+professionId+"departmentId"+departmentId+"stuorteaId"+sId);
		if (textArea== null||textArea.equals("")) {
			textArea = "";
		} else if (content.length() == 0) {
			textArea = "";
		}
		textArea = textArea.replaceAll("\n", "<br>");
		textArea = textArea.replaceAll("\r", "<br>");
		System.out.println("转换后是啥"+textArea);
		String view = "";
		String reJsonStr = "";
		
	try {

			String fileName1 = "";
			// 获取上传文件类型的扩展名,先得到.的位置，再截取从.的下一个位置到文件的最后，最后得到扩展名
			String ext = fileName.substring(fileName.lastIndexOf(".") + 1,fileName.length());
			if(bdImage.equals("")||bdImage==null){
				// 对扩展名进行小写转换
				ext = ext.toLowerCase();
				if (ext.equals("png")) {
					fileName1 = sId + "." + ext;
				} else {
					fileName1 = sId + ".png";
				}
				
				if (fileName != "") {
					System.out.println("走哪啊");
					String path = request.getSession().getServletContext()
							.getRealPath("/images/pc/" + fileName1);// 存放位置
					File destFile = new File(path);
					String file1 = String.valueOf(destFile);
					map.put("headIcon", fileName1);
					System.out.println("apkFile.getInputStream()"+apkFile.getInputStream());
					
					FileUtils.copyInputStreamToFile(apkFile.getInputStream(),destFile);// 复制临时文件到指定目录下
					
				} else {
					System.out.println("走哪啊1");
					map.put("headIcon", "");
				}
			}else{
				//说明选择的是项目原有图片
				System.out.println("说明选择的是项目原有图片");
				map.put("headIcon", fileName);
			}
			

			System.out.println("密码是啥"+pwd);

			map.put("userContect", textArea);
			map.put("stuorteaId", sId);
			map.put("userName", userName);
			map.put("userSex", userSex);
			map.put("telephoneNum", tel);
			map.put("departmentId",departmentId);
			map.put("professionId",professionId);
			map.put("password", pwd);
			
			System.out.println("图片是啥啊"+map.get("headIcon"));
			 // 往数据库里面插入
			boolean resultFlag = memberActionImpl.updateInfo(map);
			if(resultFlag){
				System.out.println("重定向了");
				if(param==2){
					//跳到教师页
					view = "redirect:/getMemberDetailById?jsonStr="+json;
				}if(param==3){
					//跳到学生页
					view = "redirect:/getMemberDetailById?jsonStr="+json1;
				}
				
			}else{
				resultMap.put("errMsg", "操作失败");
				view = "public/pageerror";
			}
			
			
		} catch (Exception e) {
			resultMap.put("errMsg", "操作失败");
			e.printStackTrace();
			logger.error("上传头像失败", e);
			view = "public/pageerror";

		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(view, returnMap);
	}
	
	/**
	 * @param request
	 * @param response
	 * @return  通过sid查询当前人的角色是否是教师
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getMemberByStuorteaId", method = RequestMethod.POST)
	public void getMemberByStuorteaId(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		System.out.println("走这个查询添加人员是否是教师了吗");
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		//成功失败标识
		String resultMark = "fail";
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			Map<String,Object> returnMap = memberActionImpl.getMemberByStuorteaId(String.valueOf(paramMap.get("stuorteaId")));
			resultMap.put("memberMap", returnMap.get("memberMap"));
			System.out.println("返回的map是啥啊"+returnMap);
			resultMark = (returnMap.get("resultFlag").equals("success")) ? "success" : "fail";
			resultMap.put("result", resultMark);
			if(resultMark.equals("fail")){
				resultMap.put("errorMsg", "查询失败");
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("查询失败人员出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @description xzx  添加学生
	 * @param request如果需要带班级id从这里带,给classId已经返回去了，
	 * @param response
	 * @return  跳转到添加学生页面
	 * @throws IOException
	 */
	@RequestMapping(value = "/skipAddStu", method = RequestMethod.GET)
	public ModelAndView skipAddStu(HttpServletRequest request, HttpServletResponse response,String jsonStr) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//全部院系
			List<Map<String, Object>> departmentList = departMentActionImpl.getDepartmentAll(new HashMap<String, Object>());
			paramMap.put("departMentList", departmentList);
			//获取我的消息
			List<Map<String, Object>> noticeList  = courseActionImpl.getMyNotice(request);
			paramMap.put("noticeList", noticeList);
			resultMap = paramMap;
			//添加学生页面名称
			pageName = "pc/addStu";
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转添加学生页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**xzx
	 * @dscription 添加学生
	 * @param request  院系，专业，班级，学号，姓名，性别，手机号
	 * @param response
	 * @return 
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/addStu", method = RequestMethod.POST)
	public void  addStu (HttpServletResponse response, HttpServletRequest request, String jsonStr) throws IOException {
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try { 
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//添加学生
			Map<String,Object> addMap = memberActionImpl.addStu(paramMap);
			if((Boolean)addMap.get("result")){
				resultMap.put("result", "success");
			}else{
				resultMap.put("result", "fail");
				resultMap.put("failMsg", addMap.get("failMsg"));
			}

		} catch (Exception e) {
			e.printStackTrace();
			logger.error("添加学生出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @param request
	 * @param response
	 * @return  重置密码
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
	public void resetPwd(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		//成功失败标识
		String resultMark = "fail";
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			// 重置密码
			Map<String, Object> resultFlag = memberActionImpl.resetPwd(paramMap);
			resultMark = (resultFlag.get("result").equals("true")) ? "success" : "fail";
			resultMap.put("result", resultMark);
			resultMap.put("errorMsg", resultFlag.get("errorMsg"));
			
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("添加人员出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @param 班级下的学生
	 * @return  班级id
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getMemberByClassId", method = RequestMethod.GET)
	public ModelAndView getMemberByClassId(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		System.out.println("班级详情");
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
		
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//获取人员列表信息
			Map<String, Object> resultAllMap = memberActionImpl.getMemberByClassId(preParamMap);
			System.out.println("参数不对"+preParamMap);
			//获取该班级对应的课程以及任课教师信息
			List<Map<String, Object>> courseList = classActionImpl.getCourseByClassId(preParamMap);
			resultMap.put("courseList", courseList);
			//返回值
			resultMap.put("memberList",resultAllMap.get("memberList"));
			resultMap.put("totalPage",resultAllMap.get("totalPage"));
			resultMap.put("pageSize",10);
			resultMap.put("preParamMap",preParamMap);
			//查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			pageName = "pc/classDetail";
		    
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("班级详情页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}

	/**
	 * @description 带参数跳转想要去的页面
	 * @param jsonStr : pageName:页面名，带前面文件夹，paramData 参数数据
	 * @return  roleId 角色，stuorteaId 工号，paramData 参数
	 * */
	@RequestMapping(value = "/skipPage", method = RequestMethod.GET)
	public ModelAndView skipPage(String jsonStr, HttpServletRequest request)  {

		Logger logger = Logger.getLogger(MemberAction.class.getName());

		Map<String, Object> resultMap = Maps.newHashMap();
		Map<String, Object> returnMap = new HashMap<String, Object>();
		ObjectMapper mapper = new ObjectMapper();
		try {
			resultMap = mapper.readValue(jsonStr, resultMap.getClass());
			resultMap.put("pageName",resultMap.get("pageName"));
			returnMap.put("result", new ObjectMapper().writeValueAsString(resultMap));
			return new ModelAndView((String)resultMap.get("pageName"), returnMap);
		} catch (IOException e) {
			e.printStackTrace();
			logger.error("跳页异常skipPage",e);
			returnMap.put("result", "fail");
			returnMap.put("failMsg", "跳转页面失败");
			return new ModelAndView("error", returnMap);
		}


	}
	
}